package model

import org.uqbar.arena.windows.SimpleWindow
import unq.model.Villano
import org.uqbar.arena.windows.WindowOwner
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.widgets.Label
import org.uqbar.arena.widgets.TextBox
import org.uqbar.arena.layout.ColumnLayout
import org.uqbar.arena.widgets.List
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.Selector
import org.uqbar.commons.utils.Observable

@Observable
class VillanoEditableWindow extends SimpleWindow<Villano> {

	new(WindowOwner parent,Villano villano) {
		super(parent, villano)
	}

	
	override protected createFormPanel(Panel mainPanel) {

      
		mainPanel.setLayout(new ColumnLayout(2))
		new Label(mainPanel) => [text = "   " fontSize = 13]
		new Label(mainPanel) => [text = "Nombre" fontSize = 13]
		new TextBox(mainPanel) => [bindValueToProperty("nombre") fontSize = 13]

		new Label(mainPanel) => [text = "Sexo" fontSize = 13]
		new Selector(mainPanel) => [
			bindItemsToProperty("posiblesSexo")
			bindValueToProperty("sexo")
		]

		new Label(mainPanel) => [text = "Señas Particulares" fontSize = 13]
		new Button(mainPanel) => [
			caption = "Editar Señas Particulares"
			onClick[ |
				new EditorCaraceristicas<Villano>(this, this.modelObject, "seniasParticulares", "elemAgregar",
					"elemEliminar", "agregarSenia", "eliminarSenia").open
			]
		]
		
		new List(mainPanel) => [
			bindItemsToProperty("seniasParticulares")
			width = 200
			heigth = 50
		]
		
		new Label(mainPanel) => [text = "     " fontSize = 13]
		
		new Label(mainPanel) => [text = "Hobbies" fontSize = 13]
		new Button(mainPanel) => [
			caption = "Editar Hobbies"
			onClick[ |
				new EditorCaraceristicas<Villano>(this, this.modelObject, "hobbies", "elemAgregar",
					"elemEliminar", "agregarHobbie", "eliminarHobbie").open
			]
		]
		
		new List(mainPanel) => [
			bindItemsToProperty("hobbies")
			width = 200
			heigth = 50
		]
		
		

//		new Panel(mainPanel) => [
//			crearPanelDeSeñas(it)
//			crearPanelDeHobbies(it)
//		]

	}
	
	override protected addActions(Panel mainPanel) {
		new Button(mainPanel) => [
			caption = "Aceptar"
			onClick[ |
				close
			]
		]
	}
	

//	def crearPanelDeHobbies(Panel panel) {
//		throw new UnsupportedOperationException("TODO: auto-generated method stub")
//	}
//
//	def crearPanelDeSeñas(Panel panel) {
//		throw new UnsupportedOperationException("TODO: auto-generated method stub")
//	}

}
